@extends('adminDialog')
@section('content')
    <form action="{{url('admin/financial/newsupdate/'.$news->id)}}" method="POST" class="J_ajaxForm">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <div class="pop_cont pop_table" style="overflow-y: scroll;height: 500px;">
            <table width="100%">
                <tbody>
                <tr>
                    <th>
                        <label for="title">标题</label>
                    </th>
                    <td>
                        <input type="text" name="title" value="{{$news->title}}" class="input length_6"  />
                    </td>
                </tr>
                <tr>
                    <th>
                        <label for="title">副标题</label>
                    </th>
                    <td>
                        <input type="text" name="subtitle" value="{{$news->subtitle}}" class="input length_6" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <label for="title">新闻类型</label>
                    </th>
                    <td>
                        <select name="type">
                            {{--<option value="">--请选择--</option>--}}

                            <option value="1" @if (1==$news->type)selected="selected" @endif>锦囊妙计</option>
                            <option value="2" @if (2==$news->type)selected="selected" @endif >最新公告</option>
                            <option value="3" @if (3==$news->type)selected="selected" @endif >公司新闻</option>
                            <option value="4" @if (4==$news->type)selected="selected" @endif >最新活动</option>
                            <option value="5" @if (5==$news->type)selected="selected" @endif >媒体报道</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th>
                        <label for="title">图片:<span class="red">*</span></label>
                    </th>
                    <td class="uploadimg" >
                        @foreach($news->img as $key=>$images)
                            <span>
                                <img title="图片" src="{{$images}}">
                                <input type="hidden" name="img[]" value="{{$images}}">
                                <a href="javascript:void(0);">X</a>
                            </span>
                        @endforeach
                        <a href="javascript:;" id="pickfiles" class="pickfiles" title="选择上传文件">
                            <img src="" onerror="this.src='{{url("images/defaltPic.jpg")}}'"/>
                        </a>
                    </td>
                </tr>
                {{--<tr>--}}
                    {{--<th>--}}
                        {{--<label for="title">简介</label>--}}
                    {{--</th>--}}
                    {{--<td>--}}
                        {{--<script id="container" name="content" type="text/plain">--}}

                        {{--</script>--}}
                    {{--</td>--}}
                {{--</tr>--}}
                <tr>
                    <th>
                        <label for="title">内容:</label>
                    </th>
                    <td>
                        <script id="container1" name="content" type="text/plain">
                            {!! $news->content !!}
                        </script>
                    </td>
                </tr>

                </tbody>
            </table>
        </div>

        <div class="pop_bottom cc">
            <button type="reset" class="btn fr" id="J_dialog_close">取消</button>
            <button type="submit" class="btn btn_submit J_ajax_submit_btn fr mr10" id="J_dialog_close">提交</button>
        </div>
    </form>
@stop

@section('style')
    <style type="text/css">
        .body_none {
            width: 720px;
        }
    </style>
@stop

@section('js')
    @parent
    @include('UEditor::head')
    <script src="{{ asset('js/plupload/plupload.full.min.js') }}"></script>
    <script>
        var ue = UE.getEditor('container', {
            initialFrameWidth: 600, initialFrameHeight: 300, autoHeightEnabled: false, toolbars: [
                ['source', 'undo', 'redo', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc'],
                ['link', 'simpleupload', 'insertimage','fontsize']
            ]
        });
        var ue1 = UE.getEditor('container1', {
            initialFrameWidth: 600, initialFrameHeight: 300, autoHeightEnabled: false, toolbars: [
                ['source', 'undo', 'redo', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc'],
                ['link', 'simpleupload', 'insertimage','fontsize']
            ]
        });
        ue.ready(function () {
            ue.execCommand('serverparam', '_token', "{{ csrf_token() }}");//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值.
        });
        ue1.ready(function () {
            ue1.execCommand('serverparam', '_token', "{{ csrf_token() }}");//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值.
        });
    </script>
    <script>
        $(function () {
            var uploader = new plupload.Uploader({
                runtimes: 'html5,flash,silverlight,html4',
                browse_button: 'pickfiles', // you can pass in id...
                //container: document.getElementById('container'), // ... or DOM Element itself
                url: "{{ url('upimg') }}",
                filters: {
                    max_file_size: '10mb',
                    mime_types: [
                        {title: "Image files", extensions: "jpg,gif,png"}
                    ]
                },
                multi_selection: false,
                file_data_name: 'file',
                multipart_params: {'_token': '{{ csrf_token() }}', 'dir': 'news'},
                // Flash settings
                flash_swf_url: '{{ asset("js/plupload/Moxie.swf") }}',
                // Silverlight settings
                silverlight_xap_url: '{{ asset('js/plupload/Moxie.xap') }}',

                init: {
                    PostInit: function () {
                        return false;
                    },
                    FilesAdded: function (up, file) {
                        $('.up-pic img').attr('src', '{{ asset('images/loading.gif') }}');
                        uploader.start();
                    },
                    Error: function (up, err) {
                        tips(err.message);
                    },
                    FileUploaded: function (up, file, responseObj) {
                        var response = $.parseJSON(responseObj.response);
                        if (response.state == 'success') {
                            var　imgString = '<span><img title="图片" src="' + response.src + '"/><input type="hidden" name="img[]" value="' + response.src + '"/><a href="javascript:void(0);">X</a></span>';
                            $(".uploadimg").prepend(imgString);

                        } else {
                            tips(response.message);
                        }
                    }
                }
            });
            uploader.init();

            $(".uploadimg").on("click", "span a", function(){
                $(this).parent().remove();
            });

        });

    </script>

@stop
